package com.lagou.controller;

import com.lagou.controller.mockdata.Jobs;
import com.lagou.entity.Job;
import com.lagou.entity.RestResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.security.DrbgParameters;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api")
public class MockController {

    @GetMapping("/user/login")
    public RestResult userLogin(@RequestParam String username, @RequestParam String password) {
        RestResult restResult = new RestResult();
        restResult.setStatus(0);
        restResult.setMessage("登录成功");

        return restResult;
    }

    @GetMapping("/jobList")
    public RestResult<List<Job>> jobList(@RequestParam int page) {
        int pageSize = 10;
        List<Job> jobs = Jobs.jobs.subList(pageSize * (page - 1), pageSize * page);

        return new RestResult<>(jobs);
    }

    @GetMapping("/jobDetail")
    public RestResult<Job> jobDetail(@RequestParam int jobId) {
        Job job = Jobs.jobMap.getOrDefault(jobId, null);

        return new RestResult<>(job);
    }

    @GetMapping("/jobCollect")
    public RestResult jobCollect(@RequestParam int jobId) {
        return new RestResult(0, "收藏成功");
    }

    @GetMapping("/sendCV")
    public RestResult sendCV(@RequestParam int jobId, @RequestParam int cvId) {
        return new RestResult(0, "投递成功");
    }

    @GetMapping("/uploadCV")
    public RestResult<Integer> uploadCV(@RequestParam String content) {

        return new RestResult(12345);
    }

}
